package com.dyna.api.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

@Data
@ApiModel("OAuth2 客户端表")
@TableName(value = "system_oauth2_client", autoResultMap = true)
public class SystemOath2Client {

    @ApiModelProperty("编号，数据库自增")
    @TableId
    private Long id;

    @ApiModelProperty("客户端编号")
    private String clientId;

    @ApiModelProperty("客户端密钥")
    private String secret;

    @ApiModelProperty("应用名")
    private String name;

    @ApiModelProperty("应用图标")
    private String logo;

    @ApiModelProperty("应用描述")
    private String description;

    @ApiModelProperty(value = "状态", notes = "枚举 {@link CommonStatusEnum}")
    private Integer status;

    @ApiModelProperty("访问令牌的有效期")
    private Integer accessTokenValiditySeconds;

    @ApiModelProperty("刷新令牌的有效期")
    private Integer refreshTokenValiditySeconds;

    @ApiModelProperty("可重定向的 URI 地址")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> redirectUris;

    @ApiModelProperty(value = "授权类型（模式）", notes = "枚举 {@link OAuth2GrantTypeEnum}")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> authorizedGrantTypes;

    @ApiModelProperty("授权范围")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> scopes;

    @ApiModelProperty(value = "自动授权的 Scope", notes = "code 授权时，如果 scope 在这个范围内，则自动通过")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> autoApproveScopes;

    @ApiModelProperty("权限")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> authorities;

    @ApiModelProperty("资源")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> resourceIds;

    @ApiModelProperty("附加信息，JSON 格式")
    private String additionalInformation;

}
